﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ProgNetComponentsDx.Controls
{
    public partial class BackgroundControlSingleThread : BackgroundControlBase
    {
        public BackgroundControlSingleThread()
        {
            InitializeComponent();
        }
        private object _Argument;

        [Browsable(false)]
        public object Argument
        {
            get { return _Argument; }
            set
            {
                if (!_IsRunning)
                    _Argument = value;
            }
        }
        
        public event DoWorkEventHandler DoWork;

        protected override void RunMainWorker()
        {
            backgroundWorker1.RunWorkerAsync(Argument);
        }

        protected override void OnDoWork()
        {
            if (DoWork != null)
            {
                DoWork(backgroundWorker1, new DoWorkEventArgs(Argument));
            }
        }
    }
}
